import {Component, Input} from '@angular/core';
import {DhlCommonInputComponent} from '../../dhlCommonInput';

@Component({
  selector: 'dhl-auto-input',
  templateUrl: './dhl-auto-input.component.html'
})
export class DhlAutoInputComponent extends DhlCommonInputComponent {

  sreOptions = [];
  optionValue = [];

  @Input() set options(value) {
    this.sreOptions = value || [];
    this.optionValue = value || [];
  };

  change(e) {
    const value = (e.target as HTMLInputElement).value;
    if (value) {
      this.optionValue = this.sreOptions.filter((item) => item.toUpperCase().indexOf(value.toUpperCase()) > -1);
    } else {
      this.inputValue = [];
      this.optionValue = this.sreOptions;
    }
  }

}




